function a=subsasgn(a,s,x)

  sd = s;
  sd.subs = {':',s.subs{:}};

  
  switch s.type
   case '()'
    if ~isa(x,'der1')
      a.v = subsasgn(a.v,s,x);
      a.d = subsasgn(a.d,sd,0);
    else
      a.v = subsasgn(a.v,s,x.v);
      a.d = subsasgn(a.d,sd,x.d);
    end
   otherwise
    error('wrong index type for_ der1');
  end
